package mumu.android.view;

import mumu.android.R;
import mumu.android.lib.view.MyViewGroup;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * http://blog.csdn.net/qinjuning/article/details/7110211
 * 
 * @author Administrator
 * 
 */
public class view_customer extends Activity {
	public String TAG = "MyViewGroup";
	private Button btn;
	private TextView txt;
	private MyViewGroup myViewGroup;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_customer);

		// setContentView(new MyViewGroup(MainActivity.this));

		// 获得main.xml的控件引用
		btn = (Button) findViewById(R.id.btn);
		txt = (TextView) findViewById(R.id.txt);
		myViewGroup = (MyViewGroup) findViewById(R.id.custemViewGroup);

		// 点击我查看绘制流程
		btn.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// if(txt.getVisibility() == View.VISIBLE)
				// txt.setVisibility(View.INVISIBLE) ;
				// else
				// txt.setVisibility(View.INVISIBLE) ;

				// myViewGroup.invalidate() ;
				// if(myViewGroup.getVisibility() == View.VISIBLE)
				// myViewGroup.setVisibility(View.GONE) ;
				// else
				// myViewGroup.setVisibility(View.VISIBLE) ;
				//
				myViewGroup.requestFocus();
				myViewGroup.invalidate();
				myViewGroup.requestLayout();
			}
		});
		Log.i(TAG, "onCreate");
	}

	@Override
	protected void onStart() {
		Log.i(TAG, "onStart");
		super.onStart();
	}

	@Override
	protected void onRestart() {
		super.onRestart();
		Log.i(TAG, "onRestart");
	}

	@Override
	protected void onResume() {
		super.onResume();
		Log.i(TAG, "onResume");
	}

	@Override
	protected void onPause() {
		Log.i(TAG, "onPause");
		super.onPause();
	}

	@Override
	protected void onStop() {
		Log.i(TAG, "onStop");
		super.onStop();
	}

	@Override
	public void setContentView(int layoutResID) {
		Log.i(TAG, "setContentView");
		super.setContentView(layoutResID);
	}

}